/***
  * @file ChartsStorage.h
  * @author Maciej Siczek
  * @author Przemyslaw Plutecki
  */
#pragma once
#ifndef CHARTSSTORAGE_H
#define CHARTSSTORAGE_H
#include <boost/noncopyable.hpp>
#include <boost/serialization/access.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/vector.hpp>
#include "Series.h"
#include "../charts/basic/Chart.h"
#include "../charts/common/Axis.h"
namespace LightChart {
/**
        @class ChartsStorage
        @author Maciej Siczek, Przemyslaw Plutecki
        @version 1.0
        @brief This class is responsible for holding Charts and binded axes, series.

        @see Storage, SeriesStorage
    */
typedef std::map <Chart *, std::map<Axis *, std::vector<Series *> > > chart_map;
class ChartsStorage : public boost::noncopyable, public chart_map {
public:
    void add (Chart * chart); ///< adds Charts @param Chart * chart
    void remove (Chart * chart); ///< removes Charts @param Chart * chart
    virtual ~ChartsStorage();
private:
    friend class boost::serialization::access;
    template <class Archive> void serialize(Archive & ar, const unsigned int version);
protected:
    std::pair<iterator,bool> insert(const value_type &__x) {
        return chart_map::insert(__x);
    }
    iterator insert (iterator position, const value_type& x) {
        return chart_map::insert(position, x);
    }
    template <class InputIterator> void insert (InputIterator first, InputIterator last) {
        chart_map::insert(first, last);
    }
    void erase (iterator position) {
        chart_map::erase(position);
    }
    size_type erase (const key_type& x) {
        return chart_map::erase(x);
    }
    void erase (iterator first, iterator last) {
        chart_map::erase(first, last);
    }
    void swap (chart_map & mp) {
        chart_map::swap(mp);
    }
    void clear () {
        chart_map::clear();
    }
};
template <class Archive> inline void ChartsStorage::serialize(Archive & ar , const unsigned int /*version*/) {
    ar & boost::serialization::base_object<chart_map>(*this);
}
}
#endif // CHARTSSTORAGE_H
